from django.db import models

# Create your models here.


class Book(models.Model):
    title = models.CharField(max_length=32)
    price = models.CharField(max_length=32)
    pub_date = models.DateTimeField(auto_now_add=True)
    publish = models.ForeignKey(to='Publish', on_delete=models.CASCADE, null=True)
    author = models.ManyToManyField(to='Author')

    def __str__(self):
        return self.title


class Publish(models.Model):
    name = models.CharField(max_length=32)
    email = models.EmailField()

    def __str__(self):
        return self.name + 'cc'


class Author(models.Model):
    name = models.CharField(max_length=32)
    age = models.IntegerField()

    def __str__(self):
        return self.name

